public with sharing class NewCourseController {

    //Course__c addCourse;
    Course__c newCourse;
    public Course__c getNewCourse() {
    if(newCourse==null)newCourse = new Course__c();
        return newCourse;
    }
    
    /*public void setNewCourse() {
        
    }*/
    
    public PageReference save() {
        try{
            insert newCourse;
            PageReference courseDetails = Page.Course;
            courseDetails.getParameters().put('id', newCourse.id);
            return courseDetails;
        }catch(Exception e){
            System.debug('An error has ocurred (NewCourseController): Error '+e.getMessage()); 
            ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR, 'Sorry. An error has ocurred'));
            return null;
        }
        
    }
    
    public PageReference cancel() {
        return Page.Training;
    }


}